from flask import Flask, request, jsonify
from rec_content import *
from flask_cors import CORS

app = Flask(__name__)
CORS(app)


# 根据国家和类型进行推荐
@app.route('/recommend_by_country_and_genre', methods=['POST'])
def recommend_by_country_and_genre():
    data = request.json
    print(data)
    country = data['country']
    genre = data['genre']
    recommendations = rec_by_country_and_genre(country, genre)
    return jsonify(recommendations)


# 根据喜欢的电影进行推荐
@app.route('/recommend_by_movie', methods=['POST'])
def recommend_by_movie():
    data = request.json
    liked_movie = data['liked_movie']
    recommendations = rec_by_movie(liked_movie)
    return jsonify(recommendations)


if __name__ == '__main__':
    app.run(host='0.0.0.0', debug=True)

